


use "[Folder]\Firm_Labor_Intermediate.dta"

drop if year <2014
merge m:1 KU1Ssyk4 using "[Data Folder]\ssyk12_isco08_up.dta"  , keepusing(iti nr_ca nr_ci rc rm nr_mp)
drop if _merge==2
drop _merge
save "[Folder]\Firm_Labor_Intermediate_nrAdded.dta", replace

use "[Folder]\Firm_Labor_Intermediate.dta"
drop if year==2014
merge m:1 KU1Ssyk4 using  "[Data Folder]\ssyk96_isco08_up.dta"  , keepusing(iti nr_ca nr_ci rc rm nr_mp)
drop if _merge==2
drop _merge

append using "[Folder]\Firm_Labor_Intermediate_nrAdded.dta"
save "[Folder]\Firm_Labor_Intermediate_nrAdded.dta", replace



use "[Folder]\Firm_Labor_Intermediate_nrAdded.dta", clear

keep LopNr_PeOrgNr KU1Ssyk4 KU1Ink year FR_Incl nr_mp nr_ca rm rc iti nr_ci Org_Sni2007
gen nr = nr_mp+nr_ca -rm-rc

sort KU1Ssyk4 year FR_Incl 
by KU1Ssyk4 year: egen Ind4_nr=mean(nr) if FR_Incl==1
by KU1Ssyk4 year: egen Ind4_iti=mean(iti) if FR_Incl==1
bysort Org_Sni2007 year: egen Sni_nr=mean(nr) if FR_Incl==1

keep LopNr_PeOrgNr year FR_Incl  KU1Ink  Ind4_nr nr_ca nr_mp rm rc nr Ind4_iti Ind4_iti iti nr_ci Sni_nr


collapse  Ind4_nr nr_ca nr_mp rm rc nr Ind4_iti iti nr_ci Sni_nr,  by(LopNr_PeOrgNr year )

xtile Ind4_nr_q = Ind4_nr , nq(4) 


save "[Folder]\IndFirm_nr.dta" , replace

